package com.xpf.service;

import com.github.pagehelper.PageInfo;
import com.xpf.utils.PagedGridResult;

import java.util.List;

public class BaseService {

    /**
     * 将pageInfo在封装一次，封装成自己项目想要的返回内容
     * @param list
     * @param page
     * @return
     */
    public PagedGridResult setterPageGrid(List<?> list, Integer page){
        PageInfo<?> pageInfo = new PageInfo<>(list);
        PagedGridResult grid = new PagedGridResult();
        grid.setPage(page);
        grid.setRows(list);
        grid.setTotal(pageInfo.getPages());
        grid.setRecords(pageInfo.getTotal());
        return grid;
    }
}
